<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <img src="" id="myimg" />
</body>
<script>
    fetch("http://localhost:8081/getimg")
        .then(res => res.blob()) //响应数据为二进制
        .then(data => {
            //console.log(data); //得到的真实数据
            let imgurl = URL.createObjectURL(data);
            document.getElementById("myimg").src = imgurl;
        }) 
        .catch(err => {
            console.log(err)
        })
</script>
</html>